package com.achievo.know.domain;

import java.io.UnsupportedEncodingException;
import java.sql.Blob;
import java.sql.SQLException;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.dayatang.domain.BaseEntity;
import com.dayatang.domain.InstanceFactory;


@Entity
@Table(name="RAMS_CATE_CONTENT")
public class CategoryContent extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5355569824684959472L;
	//内容
	@Column(name="CONTENT")
	@Lob
	private Blob content;
	
	@Transient
	private String contStr;
	
	
	@Column(name="CATE_ID")
	private Long cateId;
	
	

	

	public Long getCateId() {
		return cateId;
	}

	public void setCateId(Long cateId) {
		this.cateId = cateId;
	}

	public Blob getContent() {
		return content;
	}

	public void setContent(Blob content) {
		this.content = content;
	}

	@Override
	public boolean equals(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	private static CateContentRepository cateContentRepository;
	
	public static CateContentRepository cateContentRepository() {
		if (cateContentRepository == null) {
			cateContentRepository = InstanceFactory.getInstance(CateContentRepository.class);
		}
		return cateContentRepository;
	}

	public void add() {
		cateContentRepository().save(this);
		
	}

	public String getContStr() {
		return contStr;
	}

	public String getContString() throws SQLException {
		if(content==null)
			return "";
		return new String(content.getBytes(1, (int) content.length()));
	}
	
	public void setContStr(String contStr) {
		this.contStr = contStr;
	}
	
	
	
}
